package com.externalapi;

import android.content.Context;
import android.content.Intent;

import com.enums.TargetApi;
import com.interfaces.ExternalApiBase;
import com.result.ApiResult;

public class CloudServiceHandler implements ExternalApiBase {

	private Context context;
	private TargetApi globalTarget;
	private Intent globalIntent;

	@Override
	public ApiResult insertFile(TargetApi target, Intent file) {
		ApiResult result = new ApiResult();
		result.setSuccess(true);
		globalTarget = target;
		globalIntent = file;
		Thread t = new Thread(new Runnable() {
			@Override
			public void run() {
				ApiResult result = new ApiResult();
				if (globalTarget.equals(TargetApi.GOOGLEDRIVE)) {
					GoogleDriveApi gDriveApi = new GoogleDriveApi();
					gDriveApi.setContext(context);
					result = gDriveApi.insertFile(globalTarget, globalIntent);
				} else if (globalTarget.equals(TargetApi.SUGARSYNC)) {
					result = new SugarSyncApi().insertFile(globalTarget,
							globalIntent);
				}
			}
		});
		t.start();
		return result;
	}

	@Override
	public ApiResult createDirectory() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ApiResult deleteFile(TargetApi target, Object file) {
		ApiResult result = null;
		if (target.equals(TargetApi.GOOGLEDRIVE)) {
			result = new GoogleDriveApi().deleteFile(target, file);
		} else if (target.equals(TargetApi.SUGARSYNC)) {
			result = new SugarSyncApi().deleteFile(target, file);
		}
		return result;
	}

	@Override
	public ApiResult moveFile() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ApiResult synchronize() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public ApiResult downloadFile(TargetApi target, Object file) {
		// TODO Auto-generated method stub
		return null;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

}
